//#pragma comment(linker,"/STACK:16777216") /*16Mb*/
//#pragma comment(linker,"/STACK:33554432") /*32Mb*/
#define _CRT_SECURE_NO_DEPRECATE
#include<sstream>
#include<iostream>
#include<numeric>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<memory>
#include<string>
#include<vector>
#include<cctype>
#include<list>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<algorithm>
using namespace std;

typedef unsigned long long      ui64;
typedef long long               i64;
typedef	vector<int>             VI;
typedef	vector<bool>            VB;
typedef	vector<VI>              VVI;
typedef	vector<string>          VS;
typedef	pair<int,int>           PII;
typedef map<string,int>         MSI;
typedef set<int>                SI;
typedef set<string>             SS;
typedef map<int,int>            MII;
typedef	pair<double,double>     PDD;

#define PB                      push_back
#define MP                      make_pair
#define X                       first
#define Y                       second
#define FOR(i, a, b)            for(int i = (a); i < (b); ++i)
#define RFOR(i, a, b)           for(int i = (a) - 1; i >= (b); --i)
#define CLEAR(a, b)             memset(a, b, sizeof(a))
#define SZ(a)                   int((a).size())
#define ALL(a)                  (a).begin(), (a).end()
#define RALL(a)                 (a).rbegin(), (a).rend()
#define INF                     (2000000000)

#ifdef _DEBUG
#define eprintf(...) fprintf (stderr, __VA_ARGS__)
#else
#define eprintf(...) assert (true)
#endif

int n;
const int MAXN = 250000;
int c[MAXN], p[MAXN], cn[MAXN], pn[MAXN], cnt[MAXN];
int lcp[MAXN],lcpn[MAXN];
int WHERE[MAXN];
int lpos[MAXN], rpos[MAXN];
int tree[3*MAXN];
int A_tree[MAXN];
int N_tree;


void build_tree(int L = 0, int R = N_tree-1, int idx = 1) {
	int mid = (L+R)/2;
	if( L==R ) {
		tree[idx] = A_tree[L];
		return ;
	}
	build_tree(L,mid,idx*2);
	build_tree(mid+1,R,idx*2+1);
	tree[idx] = min(tree[idx*2], tree[idx*2+1]);
}


void call_build(int a[], int _n) {
	N_tree = _n;
	build_tree(0,_n-1,1);
}

int tree_min(int L, int R, int gL=0, int gR=N_tree-1, int idx = 1) {
	if(L==gL && R==gR)
		return tree[idx];
	int mid = (gL+gR)/2;
	if(mid>=R)
		return tree_min(L,R,gL,mid,idx*2);
	if(L>mid)
		return tree_min(L,R,mid+1,gR,idx*2+1);
	return min( tree_min(L,mid,gL,mid,idx*2), tree_min(mid+1,R,mid+1,gR,idx*2+1) );
}

void suffix_array(string s) {

	//preparing
	n = SZ(s);
	FOR(i,0,n)
		cnt[s[i]]++;
	FOR(i,1,MAXN)
		cnt[i] += cnt[i-1];
	RFOR(i,n,0)
		p[ --cnt[s[i]] ] = i;
	int rank = 0;
	c[p[0]] = 0;
	FOR(i,1,n) {
		if( s[p[i]]!=s[p[i-1]] ) rank++;
		c[p[i]] = rank;
	}

	//main part
	for(int h=0;(1<<h)<n;h++) {

		FOR(i,0,n)
			rpos[c[p[i]]] = i;
		RFOR(i,n,0)
			lpos[c[p[i]]] = i;

		memset(cnt,0,sizeof(cnt));
		FOR(i,0,n) {
			pn[i] = p[i]-(1<<h);
			if( pn[i] < 0 )
				pn[i] += n;
		}
		FOR(i,0,n)
			cnt[ c[pn[i]] ] ++;
		FOR(i,1,MAXN)
			cnt[i] += cnt[i-1];
		RFOR(i,n,0)
			p[ --cnt[ c[pn[i]] ] ] = pn[i];
		
		rank = 0;
		cn[p[0]] = 0;
		FOR(i,1,n) {
			int p1 = ( p[i] + (1<<h) )%n;
			int p2 = ( p[i-1] + (1<<h) )%n;
			if( c[p[i]]!=c[p[i-1]] || c[p1]!=c[p2] )
				rank++;
			cn[p[i]] = rank;
		}
		memcpy(A_tree,lcp,sizeof(lcp));
		call_build(lcp,n-1);
		FOR(i,0,n-1) {
			if( c[p[i]]!=c[p[i+1]] )
				lcpn[i] = lcp[ rpos[c[p[i]]] ];
			else {
				int app;
				int L = lpos[c[(p[i]+(1<<h))%n]];
				int R = rpos[c[(p[i+1]+(1<<h))%n]];
				app = tree_min(L,R-1);
				lcpn[i] = (1<<h) + app;
				lcpn[i] = min( n, lcpn[i] );
			}
		}
		memcpy(lcp,lcpn,sizeof(lcp));

		memcpy(c,cn,sizeof(cn));
	}
	/*
	printf("\t");
	FOR(i,0,n)
		printf("%d%c",p[i],i==n-1?'\n':' ');
	printf("\t");
	FOR(i,0,n)
		printf("%d%c",c[i],i==n-1?'\n':' ');
	printf("\t");
	FOR(i,0,n-1)
		printf("%d%c",lcp[i],i==n-2?'\n':' ');
	*/
}

int main()
{
	
	cin >> n;
	//aabaa - wrong
	string s;
	cin >> s;
	//s = "aabaa"; cout << s << endl;
	suffix_array(s);
	i64 ans = 0;
	FOR(i,0,n-1)
		ans += 1ll*lcp[i];
	printf("%.7lf\n",(1.0*ans)/(n-1.0));
	/*
	FOR(i,0,n)
	{
		string tmp = s.substr(p[i]) + s.substr(0,p[i]);
		cout << tmp << endl;
	}*/
    return 0;
}